







![]() ![]() |
CuttingEdge.Conditions reference library |
ValidatorExtensions..::.HasLength<(Of <(TCollection>)>) Method (ConditionValidator<(Of <(TCollection>)>), Int32, String) |
ValidatorExtensions Class See Also Send Feedback |
Checks whether the given value has the number of elements as specified by
numberOfElements. An exception is thrown otherwise. When the value is a null
reference, it is considered to have 0 elements.
Namespace:
CuttingEdge.Conditions
Assembly:
CuttingEdge.Conditions (in CuttingEdge.Conditions.dll)
Syntax
Visual Basic (Declaration) |
---|
Public Shared Function HasLength(Of TCollection As IEnumerable) ( _ validator As ConditionValidator(Of TCollection), _ numberOfElements As Integer, _ conditionDescription As String _ ) As ConditionValidator(Of TCollection) |
C# |
---|
public static ConditionValidator<TCollection> HasLength<TCollection>( ConditionValidator<TCollection> validator, int numberOfElements, string conditionDescription ) where TCollection : IEnumerable |
Visual C++ |
---|
public: generic<typename TCollection> where TCollection : IEnumerable static ConditionValidator<TCollection>^ HasLength( ConditionValidator<TCollection>^ validator, int numberOfElements, String^ conditionDescription ) |
JavaScript |
---|
JavaScript does not support generic types or methods. |
Parameters
- validator
- Type: CuttingEdge.Conditions..::.ConditionValidator<(Of <(TCollection>)>)
The ConditionValidator<(Of <(T>)>) that holds the value that has to be checked.
- numberOfElements
- Type: System..::.Int32
The number of elements the collection should contain.
- conditionDescription
- Type: System..::.String
The description of the condition that should hold. The string may hold the placeholder '{0}' for the ArgumentName.
Type Parameters
- TCollection
- The type of the value to check.
Return Value
The specified validator instance.
Exceptions
Exception | Condition |
---|---|
System..::.ArgumentException | Thrown when the Value of the specified validator does not contain the number of elements as specified with the numberOfElements argument, while the specified validator is created using the Requires extension method. |
System..::.ArgumentNullException | Thrown when the Value of the specified validator is a null reference, while numberOfElements is bigger than 0, while the specified validator is created using the Requires extension method. |
CuttingEdge.Conditions..::.PostconditionException | Thrown when the Value of the specified validator does not contain the number of elements as specified with the numberOfElements argument, while the specified validator is created using the Ensures extension method. |